import { reqCategoryList } from '@/api/index'
import { reqBannerList } from '@/api/index'
import { reqFloorList } from '@/api/index'

// home模块的小仓库
const state = {
    categoryList: [],
    bannerList: [],
    floorList: []
}
const mutations = {
    GETCATEGORYLIST(state, val) {
        // console.log(val);
        state.categoryList = val
    },
    GETBANNERLIST(state, val) {
        state.bannerList = val
    },
    GETFLOORLIST(state, val) {
        state.floorList = val
    }
}
const actions = {
    // 调接口拿数据
    async getCategoryList(context) {
        const res = await reqCategoryList()
        if (res.code === 200) {
            context.commit('GETCATEGORYLIST', res.data)
        }
    },
    async getBannerList(context) {
        const res = await reqBannerList()
        if (res.code === 200) {
            context.commit('GETBANNERLIST', res.data)
        }
    },
    async getFloorList(context) {
        const res = await reqFloorList()
        if (res.code === 200) {
            context.commit('GETFLOORLIST', res.data)
        }
    }
}
const getters = {}

export default {
    state,
    mutations,
    actions,
    getters
}